using Digitalmes.Domain.Entities.Mes.Equipments;

namespace Digitalmes.Application.Mes.Equipments.Machinery.Commands;

/// <summary>
/// 设备删除命令。
/// </summary>
/// <param name="MachineryId">设备 Id</param>
public sealed record DeleteMachineryCommand(long MachineryId) : IRequest<IResult<bool>>;

internal sealed class DeleteMachineryCommandHandler(IRepository<EquipMachinery> repo) : IRequestHandler<DeleteMachineryCommand, IResult<bool>>
{
    public async Task<IResult<bool>> Handle(DeleteMachineryCommand request, CancellationToken cancellationToken)
    {
        var ok = await repo.DeleteByIdAsync(request.MachineryId, cancellationToken);
        return Result.From(ok);
    }
}
